<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../jquery.min.js"></script>
</head>

<body>
    <div class="666">I have 666</div>
    <div>I have not 666</div>
    <div class="yeye">
        <div class="baba">
            <div class="son">我是儿子</div>
        </div>
    </div>
    <div class="mama">
        <p>我是孩子</p>
        <div>
            <p>我是孙子</p>
        </div>
    </div>
    </div>
    <ul>
        <li>我是黎吧啦</li>
        <li>我是黎吧啦</li>
        <li>我是黎吧啦</li>
        <li class="nb">我是黎吧啦</li>
        <li>我是黎吧啦</li>
        <li>我是黎吧啦</li>
        <li>我是黎吧啦</li>
        <li>我是黎吧啦</li>
    </ul>

    <script>
        $(function() {
            console.log($(".son").parent()); //父级
            $(".mama").children("p").css("color", "pink"); //子代
            $(".mama").find("p").css("background", "pink"); //后代
            $("ul .nb").siblings("li").css("color", "green"); //兄弟级
            $("ul .nb").prevAll("li").css("color", "black");
            $("ul .nb").nextAll("li").css("color", "red");
            //
            var index = 2;
            $("ul li:eq(1)").css("background", "green"); //选择器 选择索引为1的元素
            $("ul li").eq(index).css("background", "yellow");
            //
            console.log($("div:first").hasClass("666"));
            console.log($("div:last").hasClass("666"));

        });
    </script>
</body>

</html>